for i in range(10):
    s = input()
    k_open_s = 0
    k_close_s = 0
    k_open_kv = 0
    k_close_kv = 0
    k_open_kr = 0
    k_close_kr = 0
    for i in range(len(s)):
        if s[i] == '(':
            k_open_s += 1
        if s[i] == '[':
            k_open_kv += 1
        if s[i] == '{':
            k_open_kr += 1
        if s[i] == ')':
            k_close_s += 1
        if s[i] == ']':
            k_close_kv += 1
        if s[i] == '}':
            k_close_kr += 1
    if k_open_s - k_close_s == 0 and k_open_kv - k_close_kv== 0 and k_open_kr - k_close_kr == 0:
        print("True")
    else:
        print("False")